package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.ProFeedback;
import com.qidianit.mes.pro.mapper.ProFeedbackMapper;
import com.qidianit.mes.pro.service.ProFeedbackService;
import com.qidianit.mes.vo.ProFeedbackPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Package Path: com.qidianit.mes.pro.service.impl
 * Author: Alhz
 * Description:
 * Date: 2025/9/25 16:29
 */
@Service
public class ProFeedbackServiceImpl implements ProFeedbackService {
    @Autowired
    private ProFeedbackMapper proFeedbackMapper;


    /**
     * 分页查询生产报工
     * @param proFeedbackPageVO
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public Result selectAll(ProFeedbackPageVO proFeedbackPageVO, int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<ProFeedback> proFeedbacks = proFeedbackMapper.selectAll(proFeedbackPageVO);
        PageInfo<ProFeedback> pageInfo = new PageInfo<>(proFeedbacks);
        return Result.success(pageInfo);
    }



    /**
     * 根据id查询报工内容
     * @param recordId
     * @return
     */
    @Override
    public Result selectFeedbackById(Integer recordId) {
        return Result.success(proFeedbackMapper.selectFeedbackById(recordId));
    }

    /**
     * 添加报工
     * @param proFeedback
     * @return
     */
    @Override
    public Result insertFeedback(ProFeedback proFeedback) {
        proFeedback.setCreateTime(LocalDateTime.now());
        proFeedback.setUpdateTime(LocalDateTime.now());
        proFeedback.setDeleteFlag(0);
        return Result.success(proFeedbackMapper.insertFeedback(proFeedback));
    }

    /**
     * 更新报工
     * @param proFeedback
     * @return
     */
    @Override
    public Result updateFeedback(ProFeedback proFeedback) {
        return Result.success(proFeedbackMapper.updateFeedback(proFeedback));
    }

    /**
     * 删除报工
     * @param feedbackId
     * @return
     */
    @Override
    public Result deleteFeedback(Integer feedbackId) {
        return Result.success(proFeedbackMapper.deleteFeedback(feedbackId));
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @Override
    public Result batchDeleteFeedback(Long[] ids) {
        return Result.success(proFeedbackMapper.batchDeleteFeedback(ids));
    }

    @Override
    public List<ProFeedback> selectAllFeedback() {
        return proFeedbackMapper.selectAllFeedback();
    }
}
